import java.util.Scanner;

public class Login {
    static final String uName = "Matty";
    static final String pWord = "2020040108";

    public static void main(String[] args) throws UNameExcpetion, PWordException {
        try {
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入用户名：");
            String name = sc.nextLine();
            if (!name.equals(uName)) {
                throw new UNameExcpetion();
            }
            System.out.print("请输入密码：");
            String word = sc.nextLine();
            if(!word.equals(pWord)) {
                throw new PWordException();
            }
            System.out.println("登录成功！");
        } catch (UNameExcpetion uNameExcpetion) {
            uNameExcpetion.printStackTrace();
            System.out.println("用户名错误！");
        } catch (PWordException pWordException) {
            pWordException.printStackTrace();
            System.out.println("密码错误！");
        }
    }
}
